package com.btr.uimeter.util;

import java.lang.instrument.Instrumentation;

import com.btr.uimeter.UIMeter;
import com.btr.uimeter.config.UIMeterConfig;

/*****************************************************************************
 * This agent class can be used to inject the UI meter into existing java
 * applications.
 * 
 * http://download.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html
 * 
 * @author Bernd Rosstauscher (java@rosstauscher.de) Copyright 2010
 ****************************************************************************/

public class Agent {
	
	/*************************************************************************
	 * Needed for the java agent loading.
	 * Needs a entry in the jar manifest like this
	 * 
	 * Premain-Class:  com.btr.uimeter.util.Agent
	 * 
	 * @param agentArgs
	 * @param inst
	 ************************************************************************/
	
	public static void premain(String agentArgs, Instrumentation inst) {
		// TODO rossi 14.02.2010 configure the library 
		// agentArgs names the config file if none is set load from a default file.
		UIMeterConfig.setupWithDefaultConfig();
		UIMeter.getInstance().startMonitoring();
	}

}

